package br.gov.ibama.client.componentes;

import com.smartgwt.client.data.DataSource;
import com.smartgwt.client.widgets.form.fields.ComboBoxItem;

public class ComboGenericaDS extends ComboBoxItem {

	public ComboGenericaDS(String name, String title, String datasource,
			String campoChave, String campoShow) {
		super(name, title);
		configurarCombo(datasource, campoChave, campoShow);
	}

	private void configurarCombo(String datasource, String campoChave,
			String campoShow) {
		this.setOptionDataSource(DataSource.get(datasource));
		this.setValueField(campoChave);
		this.setDisplayField(campoShow);
		this.setAddUnknownValues(false);
		this.setDefaultToFirstOption(true);
	}

	public void setaValor(String valor) {
		this.setDefaultValue(valor);
	}
}
